package gui;

import java.awt.Component;

import javax.swing.DefaultListCellRenderer;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
/**
 * 
 * @author Christian
 *
 */
public class HauptFensterListCellRenderer implements ListCellRenderer {

	/**
	 * 
	 */
	private DefaultListCellRenderer defaultRenderer = new DefaultListCellRenderer();

	/**
	 * @param list Aktuelle Liste
	 * @param value Wert an der Stelle
	 * @param index Indes des Elements
	 * @param isSelected Isselected
	 * @param cellHasFocus HasFokus?
	 * 
	 * @return Komponente
	 */
	@Override
	public Component getListCellRendererComponent(JList list, Object value, int index,
						boolean isSelected, boolean cellHasFocus) {

		JLabel renderer = (JLabel) defaultRenderer.getListCellRendererComponent(list, value, index,
							isSelected, cellHasFocus);
		if (value.toString().length() > 34) {
			renderer.setText(value.toString().substring(0, 33) + "...");
		}
		return renderer;
	}
}
